SlideShare a Scribd company logo
1 of 54
JAVA SCRIPT
LOADING….
INTRODUCTION JavaScript (aka ECMAScript) is an easy way to make your website visually attractive to clients and other viewers by adding interactivity and dynamics to HTML pages.   Explains ABOUT:                            why one would use JavaScript in their HTML website design.                           It also has links to JavaScript tools, readings and samples for                                     those who prefer ready-to-run effects.
What is java script JavaScript is the most popular scripting language on the internet, and works in all major browsers, such as Internet Explorer, Firefox Chrome, Opera, and Safari. JavaScript is a scripted language which is  object oriented,  event-driven, and  platform independent. Each of these modern concepts in programming methodology are easier to work with in 'new' languages rather than being bolted on to older ones.  And the syntax is similar to that of C and Java. This makes JavaScript a 'good' choice for learning as a first programming language.
JavaScript was designed to add interactivity to HTML pages  JavaScript is a scripting language  A scripting language is a lightweight programming language JavaScript is usually embedded directly into HTML pages JavaScript is an interpreted language (means that scripts execute without preliminary compilation)  Everyone can use JavaScript without purchasing a license
Why should a webpage author use JavaScript in addition to HTML?
Java script  allows  client-side user form validation Java script provides seamless integration with user plug-ins Java script allows access to some system information
Are Java and JavaScript the same? NO! Java and JavaScript are two completely different languages in both concept and design! Java (developed by Sun Microsystems) is a powerful and much more complex programming language - in the same category as C and C++.
The Real Name is ECMAScript: JavaScript's official name is ECMAScript. ECMAScript is developed and maintained by the ECMA organization. ECMA-262 is the official JavaScript standard. The language was invented by Brendan Eich at Netscape (with Navigator 2.0), and has appeared in all Netscape and Microsoft browsers since 1996. The development of ECMA-262 started in 1996, and the first edition of was adopted by the ECMA General Assembly in June 1997. The standard was approved as an international ISO (ISO/IEC 16262) standard in 1998. The development of the standard is still in progress.
EXAMPLES Put a JavaScript into an HTML page <html><body><script type="text/javascript">document.write("Hello World!");</script></body></html>  HELLO WORLD
JavaScript is Case Sensitive: Unlike HTML, JavaScript is case sensitive - therefore watch your capitalization closely when you write JavaScript statements, create or call variables, objects and functions. JavaScript Statements: A JavaScript statement is a command to a browser. The purpose of the command is to tell the browser what to do. This JavaScript statement tells the browser to write "Hello Dolly" to the web page: Note: Using semicolons makes it possible to write multiple statements on one line.
Java   Script Comments Comments can be added to explain the JavaScript, or to make the code more readable. >Single line comments start with “//”:. >JavaScript Multi-Line Comments: Multi line comments start with /* and end with */. <script type="text/javascript">// Write a headingdocument.write("<h1>This is a heading</h1>");// Write two paragraphs:document.write("<p>This is a paragraph.</p>");document.write("<p>This is another paragraph.</p>");</script>  THIS IS HEADING THIS IS HEADING THIS IS HEADING
Java variables  JavaScript Variables        As with algebra, JavaScript variables are used to hold values or expressions.  A variable can have a short name, like x, or a more descriptive name, like car name. Rules for JavaScript variable names:                               Variable names are case sensitive (y and Y are two different variables)                                Variable names must begin with a letter or the underscore character  Note:Because JavaScript is case-sensitive, variable names are case-sensitive.
Declaring (Creating) JavaScript Variables                 Creating variables in JavaScript is most often referred to as "declaring" variables.You can declare JavaScript variables with the var statement. EXAMPLE: var x;varcarname; Assigning Values to Undeclared JavaScript Variables: If you assign values to variables that have not yet been declared, the variables will automatically be declared. These statements: x=5;carname="Volvo";
Redeclaring  JavaScript Variables As with algebra, you can do arithmetic operations with JavaScript variables: y=x-5;z=y+5; JavaScript Operators = is used to assign values. + is used to add values. JavaScript Arithmetic Operators Arithmetic operators are used to perform arithmetic between variables  and/or values. Given that y=5, the table below explains the arithmetic operators:               EXAMPLES: + , -,  *,   /,  %
JavaScript Assignment Operators Assignment operators are used to assign values to JavaScript variables. Given that x=10 and y=5, the table below explains the assignment operators: OPERATORS =, += ,-=,   *=,  /=,  %= The + Operator Used on Strings The + operator can also be used to add string variables or text values together. txt1="What a very";txt2="nice day";txt3=txt1+txt2;
Adding Strings and Numbers The rule is:  If you add a number  and a string, the result will be a string! x=5+5;document.write(x);x="5"+"5";document.write(x);x=5+"5";document.write(x);x="5"+5;document.write(x);
Comparison Operators
Logical Operators Logical Operators: Logical operators are used to determine the logic between variables or values. Given that x=6 and y=3, the table below explains the logical operators:
Conditional Operator Syntax Example: If the variable visitor has the value of "PRES",  then the variable greeting will be assigned the value  "Dear President " else i  t will be assigned "Dear".
Conditional Statements: Very often when you write code, you want to perform different actions for different decisions. You can use conditional statements in your code to do this. In JavaScript we have the following conditional statements: if statement- use this statement to execute some code only if a specified condition is true     if...else statement- use this statement to execute some code if the condition is true and another code if the condition is false  if...else if....else statement- use this statement to select one of many blocks of code to be executed  switch statement - use this statement to select one of many blocks of code to be executed
Syntax
The JavaScript Switch Statement Use the switch statement to select one of many blocks of code to be executed. Syntax
JavaScript Popup Boxes Alert Box: An alert box is often used if you want to make sure information comes  through to the user.When an alert box pops up, the userwill have to click "OK" to proc Syntax alert("sometext"); Confirm Box A confirm box is often used if you want the user to verify or accept something.  When a confirm box pops up, the user will have to click either "OK" or "Cancel" to proceed.  If the user clicks "OK", the box returns true. If the user clicks "Cancel", the box returns false. Syntax confirm("sometext");
Prompt Box A prompt box is often used if you want the user to input a value before entering a page. When a prompt box pops up, the user will have to click either "OK" or "Cancel" to proceed after entering an input value. If the user clicks "OK" the box returns the input value. If the user clicks "Cancel" the box returns null. Syntax prompt("sometext","defaultvalue");
JavaScript Functions To keep the browser from executing a script when the page loads, you can put your script into a function. A function contains code that will be executed by an event or by a call to the function. You may call a function from anywhere within a page (or even from other pages if the function is embedded in an external .js file). Functions can be defined both in the <head> and in the <body> section of a document. However, to assure that a function is read/loaded by the browser before it is called, it could be wise to put functions in the <head> section. How to Define a Function function functionname(var1,var2,...,varX){some code}
Events By using JavaScript, we have the ability to create dynamic web pages. Events are actions that can be detected by JavaScript. Every element on a web page has certain events which can trigger a JavaScript. For example, we can use the onClick event of a button element to indicate that a function will run when a user clicks on the button. We define the events in the HTML tags. Examples of events:                         A mouse click                          A web page or an image loading  Mousing over a hot spot on the web page                         Selecting an input field in an HTML                         form Submitting                         an HTML form                         A keystroke
On Load and on Unload The onLoad event is often used to check the visitor's browser type and browser version, and load the proper version of the web page based on the information. Some of other events onFocus, onBlur and onChange onSubmit onMouseOver and onMouseOut
Exception handling When browsing Web pages on the internet, we all have seen a JavaScript alert box telling us there is a runtime error and asking "Do you wish to debug?". Error message like this may be useful for developers but not for users. When users see errors, they often leave the Web page. This chapter will teach you how to catch and handle JavaScript error messages, so you don't lose your audience. Try catch block  try  {  //Run some code here  }catch(err)  {  //Handle errors here  }
Throw and throws The throw statement allows you to create an exception. If you use this statement together with the try...catch statement, you can control program flow and generate accurate error messages. syntax throw(exception)
<html><body><script type="text/javascript">var x=prompt("Enter a number between 0 and 10:","");try  {   if(x>10)    {    throw "Err1";    }  else if(x<0)    {    throw "Err2";    }  else if(isNaN(x))    {    throw "Err3";    }  }>
catch(er)  {  if(er=="Err1")    {    alert("Error! The value is too high");    }  if(er=="Err2")    {    alert("Error! The value is too low");    }  if(er=="Err3")    {    alert("Error! The value is not a number");    }  }</script></body></html
Insert Special Characters The backslash ( is used to insert apostrophes, new lines, quotes, and other special characters into a text string.
JavaScriptObjects JavaScript is an Object Oriented Programming (OOP) language. An OOP language allows you to define your own objects and make your own variable types. Array Object
String object The String object is used to manipulate a stored piece of text. String objects are created with new String(). Syntax var txt = new String(string);  or  var txt = string;
Date Object Properties
RegExp Object A regular expression is an object that describes a pattern of characters. Regular expressions are used to perform pattern-matching and "search-and-replace" functions on text. Syntax ,[object Object]
modifiers specify if a search should be global, case-sensitive, etc. ,[object Object]
ADVANCED JAVA SCRIPT  OBJECTS
The Navigator Object The Navigator object contains all information about the visitor's browser. We are going to look at two properties of the Navigator object: ,[object Object]
appVersion - holds, among other things, the version of the browser Example: <html><body><script type="text/javascript">var browser=navigator.appName;varb_version=navigator.appVersion;var version=parseFloat(b_version);document.write("Browser name: "+ browser);document.write("<br />");document.write("Browser version: "+ version);</script></body></html>  OUTPUT: Browser name:Microsoft Internet Explorer Browser version:4
COOKIES A cookie is a variable that is stored on the visitor's computer.  Each time the same computer requests a page with a browser,    it will send the cookie too.With JavaScript, you can both create and  retrieve cookie values.A cookie is often used to identify a user. Examples of cookies: ,[object Object]
Password cookie - The first time a visitor arrives to your web page, he or she must fill in a password. The password is then stored in a cookie. Next time the visitor arrives at your page, the password is retrieved from the cookie
Date cookie - The first time a visitor arrives to your web page, the current date is stored in a cookie. Next time the visitor arrives at your page, he or she could get a message like "Your last visit was on Tuesday August 11, 2005!" The date is retrieved from the stored cookie ,[object Object]
JavaScript Form Validation JavaScript can be used to validate data in HTML forms before sending off the  content to a server. Javascript  perform the following checks typically: ,[object Object]
            whether E-mail id entered by user is valid or not
            whether Date entered is valid or  not
            whether  user has entered text in numerical format,[object Object]
with (thisform)  {  if (validate_required(email,"Email must be filled out!")==false)  {email.focus();return false;}  }}</script></head><body><form action="submit.htm" onsubmit="return validate_form(this)" method="post">Email: <input type="text" name="email" size="30"><input type="submit" value="Submit"></form></body></html>
JavaScript Objects Creating Your Own Objects There are different ways to create a new object: 1. Create a direct instance of an object The following code creates an instance of an object and adds four properties to it: personObj=new Object();personObj.firstname="John";personObj.lastname="Doe";personObj.age=50;personObj.eyecolor="blue"; 2. Create a template of an object The template defines the structure of an object: function person(firstname,lastname,age,eyecolor){this.firstname=firstname;this.lastname=lastname;this.age=age;this.eyecolor=eyecolor;} With the help of template ,we can create new instances of object like this:
EXAMPLE myFather=new person("John","Doe",50,"blue"); myMother=new person("Sally","Rally",48,"green");

More Related Content

What's hot

JavaScript - An Introduction
JavaScript - An IntroductionJavaScript - An Introduction
JavaScript - An IntroductionManvendra Singh
 
JavaScript & Dom Manipulation
JavaScript & Dom ManipulationJavaScript & Dom Manipulation
JavaScript & Dom ManipulationMohammed Arif
 
JavaScript Tutorial For Beginners | JavaScript Training | JavaScript Programm...
JavaScript Tutorial For Beginners | JavaScript Training | JavaScript Programm...JavaScript Tutorial For Beginners | JavaScript Training | JavaScript Programm...
JavaScript Tutorial For Beginners | JavaScript Training | JavaScript Programm...Edureka!
 
Introduction to JavaScript
Introduction to JavaScriptIntroduction to JavaScript
Introduction to JavaScriptAndres Baravalle
 
JavaScript - Chapter 8 - Objects
 JavaScript - Chapter 8 - Objects JavaScript - Chapter 8 - Objects
JavaScript - Chapter 8 - ObjectsWebStackAcademy
 
JavaScript - Chapter 5 - Operators
 JavaScript - Chapter 5 - Operators JavaScript - Chapter 5 - Operators
JavaScript - Chapter 5 - OperatorsWebStackAcademy
 
Web Development Course: PHP lecture 1
Web Development Course: PHP lecture 1Web Development Course: PHP lecture 1
Web Development Course: PHP lecture 1Gheyath M. Othman
 
Javascript operators
Javascript operatorsJavascript operators
Javascript operatorsMohit Rana
 
JavaScript Programming
JavaScript ProgrammingJavaScript Programming
JavaScript ProgrammingSehwan Noh
 

What's hot (20)

Java script
Java scriptJava script
Java script
 
JavaScript - An Introduction
JavaScript - An IntroductionJavaScript - An Introduction
JavaScript - An Introduction
 
JavaScript & Dom Manipulation
JavaScript & Dom ManipulationJavaScript & Dom Manipulation
JavaScript & Dom Manipulation
 
Java script
Java scriptJava script
Java script
 
Javascript
JavascriptJavascript
Javascript
 
jQuery for beginners
jQuery for beginnersjQuery for beginners
jQuery for beginners
 
JavaScript Tutorial For Beginners | JavaScript Training | JavaScript Programm...
JavaScript Tutorial For Beginners | JavaScript Training | JavaScript Programm...JavaScript Tutorial For Beginners | JavaScript Training | JavaScript Programm...
JavaScript Tutorial For Beginners | JavaScript Training | JavaScript Programm...
 
Introduction to JavaScript
Introduction to JavaScriptIntroduction to JavaScript
Introduction to JavaScript
 
JavaScript - Chapter 8 - Objects
 JavaScript - Chapter 8 - Objects JavaScript - Chapter 8 - Objects
JavaScript - Chapter 8 - Objects
 
JavaScript - Chapter 5 - Operators
 JavaScript - Chapter 5 - Operators JavaScript - Chapter 5 - Operators
JavaScript - Chapter 5 - Operators
 
Javascript 101
Javascript 101Javascript 101
Javascript 101
 
Js ppt
Js pptJs ppt
Js ppt
 
Javascript Basic
Javascript BasicJavascript Basic
Javascript Basic
 
Web Development Course: PHP lecture 1
Web Development Course: PHP lecture 1Web Development Course: PHP lecture 1
Web Development Course: PHP lecture 1
 
Javascript
JavascriptJavascript
Javascript
 
JavaScript: Events Handling
JavaScript: Events HandlingJavaScript: Events Handling
JavaScript: Events Handling
 
Java script basics
Java script basicsJava script basics
Java script basics
 
Javascript operators
Javascript operatorsJavascript operators
Javascript operators
 
JavaScript Variables
JavaScript VariablesJavaScript Variables
JavaScript Variables
 
JavaScript Programming
JavaScript ProgrammingJavaScript Programming
JavaScript Programming
 

Viewers also liked (20)

Javascript validating form
Javascript validating formJavascript validating form
Javascript validating form
 
Form Validation in JavaScript
Form Validation in JavaScriptForm Validation in JavaScript
Form Validation in JavaScript
 
HTML CSS & Javascript
HTML CSS & JavascriptHTML CSS & Javascript
HTML CSS & Javascript
 
Bridges to Practice
Bridges to PracticeBridges to Practice
Bridges to Practice
 
Java script202
Java script202Java script202
Java script202
 
Javascript
JavascriptJavascript
Javascript
 
Mobile Shopping
Mobile ShoppingMobile Shopping
Mobile Shopping
 
Form Validation
Form ValidationForm Validation
Form Validation
 
validation-of-email-addresses-collected-offline
validation-of-email-addresses-collected-offlinevalidation-of-email-addresses-collected-offline
validation-of-email-addresses-collected-offline
 
Java Regular Expression PART II
Java Regular Expression PART IIJava Regular Expression PART II
Java Regular Expression PART II
 
JavaScript Event Loop
JavaScript Event LoopJavaScript Event Loop
JavaScript Event Loop
 
Email Validation
Email ValidationEmail Validation
Email Validation
 
The Role Of Java Script
The Role Of Java ScriptThe Role Of Java Script
The Role Of Java Script
 
How Salesforce.com uses Hadoop
How Salesforce.com uses HadoopHow Salesforce.com uses Hadoop
How Salesforce.com uses Hadoop
 
Frames tables forms
Frames tables formsFrames tables forms
Frames tables forms
 
JavaScript Operators
JavaScript OperatorsJavaScript Operators
JavaScript Operators
 
Introdution to HTML 5
Introdution to HTML 5Introdution to HTML 5
Introdution to HTML 5
 
Html 5
Html 5Html 5
Html 5
 
An Introduction to HTML5
An Introduction to HTML5An Introduction to HTML5
An Introduction to HTML5
 
Bpr
BprBpr
Bpr
 

Similar to Javascript

Javascript survival for CSBN Sophomores
Javascript survival for CSBN SophomoresJavascript survival for CSBN Sophomores
Javascript survival for CSBN SophomoresAndy de Vera
 
8.-Javascript-report powerpoint presentation
8.-Javascript-report powerpoint presentation8.-Javascript-report powerpoint presentation
8.-Javascript-report powerpoint presentationJohnLagman3
 
Basic Java script handouts for students
Basic Java script handouts for students Basic Java script handouts for students
Basic Java script handouts for students shafiq sangi
 
Introduction to Javascript
Introduction to JavascriptIntroduction to Javascript
Introduction to Javascriptambuj pathak
 
Basics java scripts
Basics java scriptsBasics java scripts
Basics java scriptsch samaram
 
Java script Basic
Java script BasicJava script Basic
Java script BasicJaya Kumari
 
JavaScript Core fundamentals - Learn JavaScript Here
JavaScript Core fundamentals - Learn JavaScript HereJavaScript Core fundamentals - Learn JavaScript Here
JavaScript Core fundamentals - Learn JavaScript HereLaurence Svekis ✔
 
Introduction to java script
Introduction to java scriptIntroduction to java script
Introduction to java scriptnanjil1984
 
Session vii(java scriptbasics)
Session vii(java scriptbasics)Session vii(java scriptbasics)
Session vii(java scriptbasics)Shrijan Tiwari
 
Unit 4 Java script.pptx
Unit 4 Java script.pptxUnit 4 Java script.pptx
Unit 4 Java script.pptxGangesh8
 
JavaScript New Tutorial Class XI and XII.pptx
JavaScript New Tutorial Class XI and XII.pptxJavaScript New Tutorial Class XI and XII.pptx
JavaScript New Tutorial Class XI and XII.pptxrish15r890
 
JAVA SCRIPT
JAVA SCRIPTJAVA SCRIPT
JAVA SCRIPTGo4Guru
 
JavaScript - Getting Started.pptx
JavaScript - Getting Started.pptxJavaScript - Getting Started.pptx
JavaScript - Getting Started.pptxJonnJorellPunto
 
Basic JavaScript Tutorial
Basic JavaScript TutorialBasic JavaScript Tutorial
Basic JavaScript TutorialDHTMLExtreme
 

Similar to Javascript (20)

Javascript survival for CSBN Sophomores
Javascript survival for CSBN SophomoresJavascript survival for CSBN Sophomores
Javascript survival for CSBN Sophomores
 
Introduction to Java Scripting
Introduction to Java ScriptingIntroduction to Java Scripting
Introduction to Java Scripting
 
8.-Javascript-report powerpoint presentation
8.-Javascript-report powerpoint presentation8.-Javascript-report powerpoint presentation
8.-Javascript-report powerpoint presentation
 
Basic Java script handouts for students
Basic Java script handouts for students Basic Java script handouts for students
Basic Java script handouts for students
 
Introduction to Javascript
Introduction to JavascriptIntroduction to Javascript
Introduction to Javascript
 
Basics java scripts
Basics java scriptsBasics java scripts
Basics java scripts
 
Javascript tutorial
Javascript tutorialJavascript tutorial
Javascript tutorial
 
Java script Basic
Java script BasicJava script Basic
Java script Basic
 
JavaScript Core fundamentals - Learn JavaScript Here
JavaScript Core fundamentals - Learn JavaScript HereJavaScript Core fundamentals - Learn JavaScript Here
JavaScript Core fundamentals - Learn JavaScript Here
 
Introduction to java script
Introduction to java scriptIntroduction to java script
Introduction to java script
 
Session vii(java scriptbasics)
Session vii(java scriptbasics)Session vii(java scriptbasics)
Session vii(java scriptbasics)
 
Unit 4 Java script.pptx
Unit 4 Java script.pptxUnit 4 Java script.pptx
Unit 4 Java script.pptx
 
JavaScript New Tutorial Class XI and XII.pptx
JavaScript New Tutorial Class XI and XII.pptxJavaScript New Tutorial Class XI and XII.pptx
JavaScript New Tutorial Class XI and XII.pptx
 
Java scipt
Java sciptJava scipt
Java scipt
 
Unit 2.4
Unit 2.4Unit 2.4
Unit 2.4
 
JAVA SCRIPT
JAVA SCRIPTJAVA SCRIPT
JAVA SCRIPT
 
JAVA SCRIPT
JAVA SCRIPTJAVA SCRIPT
JAVA SCRIPT
 
Web programming
Web programmingWeb programming
Web programming
 
JavaScript - Getting Started.pptx
JavaScript - Getting Started.pptxJavaScript - Getting Started.pptx
JavaScript - Getting Started.pptx
 
Basic JavaScript Tutorial
Basic JavaScript TutorialBasic JavaScript Tutorial
Basic JavaScript Tutorial
 

More from Nagarajan

Scheduling algorithm (chammu)
Scheduling algorithm (chammu)Scheduling algorithm (chammu)
Scheduling algorithm (chammu)Nagarajan
 
Real time os(suga)
Real time os(suga) Real time os(suga)
Real time os(suga) Nagarajan
 
Process synchronization(deepa)
Process synchronization(deepa)Process synchronization(deepa)
Process synchronization(deepa)Nagarajan
 
Posix threads(asha)
Posix threads(asha)Posix threads(asha)
Posix threads(asha)Nagarajan
 
Monitor(karthika)
Monitor(karthika)Monitor(karthika)
Monitor(karthika)Nagarajan
 
Cpu scheduling(suresh)
Cpu scheduling(suresh)Cpu scheduling(suresh)
Cpu scheduling(suresh)Nagarajan
 
Backward chaining(bala,karthi,rajesh)
Backward chaining(bala,karthi,rajesh)Backward chaining(bala,karthi,rajesh)
Backward chaining(bala,karthi,rajesh)Nagarajan
 
Introduction Of Artificial neural network
Introduction Of Artificial neural networkIntroduction Of Artificial neural network
Introduction Of Artificial neural networkNagarajan
 
Back propagation
Back propagationBack propagation
Back propagationNagarajan
 
Adaline madaline
Adaline madalineAdaline madaline
Adaline madalineNagarajan
 

More from Nagarajan (18)

Chapter3
Chapter3Chapter3
Chapter3
 
Chapter2
Chapter2Chapter2
Chapter2
 
Chapter1
Chapter1Chapter1
Chapter1
 
Minimax
MinimaxMinimax
Minimax
 
I/O System
I/O SystemI/O System
I/O System
 
Scheduling algorithm (chammu)
Scheduling algorithm (chammu)Scheduling algorithm (chammu)
Scheduling algorithm (chammu)
 
Real time os(suga)
Real time os(suga) Real time os(suga)
Real time os(suga)
 
Process synchronization(deepa)
Process synchronization(deepa)Process synchronization(deepa)
Process synchronization(deepa)
 
Posix threads(asha)
Posix threads(asha)Posix threads(asha)
Posix threads(asha)
 
Monitor(karthika)
Monitor(karthika)Monitor(karthika)
Monitor(karthika)
 
Cpu scheduling(suresh)
Cpu scheduling(suresh)Cpu scheduling(suresh)
Cpu scheduling(suresh)
 
Backward chaining(bala,karthi,rajesh)
Backward chaining(bala,karthi,rajesh)Backward chaining(bala,karthi,rajesh)
Backward chaining(bala,karthi,rajesh)
 
Inferno
InfernoInferno
Inferno
 
Introduction Of Artificial neural network
Introduction Of Artificial neural networkIntroduction Of Artificial neural network
Introduction Of Artificial neural network
 
Perceptron
PerceptronPerceptron
Perceptron
 
Back propagation
Back propagationBack propagation
Back propagation
 
Ms access
Ms accessMs access
Ms access
 
Adaline madaline
Adaline madalineAdaline madaline
Adaline madaline
 

Recently uploaded

Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfSumit Tiwari
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxpboyjonauth
 
Biting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdfBiting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdfadityarao40181
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatYousafMalik24
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxthorishapillay1
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon AUnboundStockton
 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for BeginnersSabitha Banu
 
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,Virag Sontakke
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsanshu789521
 
History Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptxHistory Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptxsocialsciencegdgrohi
 
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfFraming an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfUjwalaBharambe
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxmanuelaromero2013
 
internship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developerinternship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developerunnathinaik
 
Meghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media ComponentMeghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media ComponentInMediaRes1
 
Hierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementHierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementmkooblal
 
Capitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptxCapitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptxCapitolTechU
 
Final demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxFinal demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxAvyJaneVismanos
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️9953056974 Low Rate Call Girls In Saket, Delhi NCR
 

Recently uploaded (20)

Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptx
 
Biting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdfBiting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdf
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice great
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptx
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon A
 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for Beginners
 
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha elections
 
History Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptxHistory Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptx
 
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfFraming an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptx
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
internship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developerinternship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developer
 
Meghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media ComponentMeghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media Component
 
Hierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementHierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of management
 
Capitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptxCapitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptx
 
Final demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxFinal demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptx
 
OS-operating systems- ch04 (Threads) ...
OS-operating systems- ch04 (Threads) ...OS-operating systems- ch04 (Threads) ...
OS-operating systems- ch04 (Threads) ...
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
 

Javascript

  • 3. INTRODUCTION JavaScript (aka ECMAScript) is an easy way to make your website visually attractive to clients and other viewers by adding interactivity and dynamics to HTML pages. Explains ABOUT: why one would use JavaScript in their HTML website design. It also has links to JavaScript tools, readings and samples for those who prefer ready-to-run effects.
  • 4. What is java script JavaScript is the most popular scripting language on the internet, and works in all major browsers, such as Internet Explorer, Firefox Chrome, Opera, and Safari. JavaScript is a scripted language which is object oriented, event-driven, and platform independent. Each of these modern concepts in programming methodology are easier to work with in 'new' languages rather than being bolted on to older ones. And the syntax is similar to that of C and Java. This makes JavaScript a 'good' choice for learning as a first programming language.
  • 5. JavaScript was designed to add interactivity to HTML pages JavaScript is a scripting language A scripting language is a lightweight programming language JavaScript is usually embedded directly into HTML pages JavaScript is an interpreted language (means that scripts execute without preliminary compilation) Everyone can use JavaScript without purchasing a license
  • 6. Why should a webpage author use JavaScript in addition to HTML?
  • 7. Java script allows client-side user form validation Java script provides seamless integration with user plug-ins Java script allows access to some system information
  • 8. Are Java and JavaScript the same? NO! Java and JavaScript are two completely different languages in both concept and design! Java (developed by Sun Microsystems) is a powerful and much more complex programming language - in the same category as C and C++.
  • 9. The Real Name is ECMAScript: JavaScript's official name is ECMAScript. ECMAScript is developed and maintained by the ECMA organization. ECMA-262 is the official JavaScript standard. The language was invented by Brendan Eich at Netscape (with Navigator 2.0), and has appeared in all Netscape and Microsoft browsers since 1996. The development of ECMA-262 started in 1996, and the first edition of was adopted by the ECMA General Assembly in June 1997. The standard was approved as an international ISO (ISO/IEC 16262) standard in 1998. The development of the standard is still in progress.
  • 10. EXAMPLES Put a JavaScript into an HTML page <html><body><script type="text/javascript">document.write("Hello World!");</script></body></html> HELLO WORLD
  • 11. JavaScript is Case Sensitive: Unlike HTML, JavaScript is case sensitive - therefore watch your capitalization closely when you write JavaScript statements, create or call variables, objects and functions. JavaScript Statements: A JavaScript statement is a command to a browser. The purpose of the command is to tell the browser what to do. This JavaScript statement tells the browser to write "Hello Dolly" to the web page: Note: Using semicolons makes it possible to write multiple statements on one line.
  • 12. Java Script Comments Comments can be added to explain the JavaScript, or to make the code more readable. >Single line comments start with “//”:. >JavaScript Multi-Line Comments: Multi line comments start with /* and end with */. <script type="text/javascript">// Write a headingdocument.write("<h1>This is a heading</h1>");// Write two paragraphs:document.write("<p>This is a paragraph.</p>");document.write("<p>This is another paragraph.</p>");</script> THIS IS HEADING THIS IS HEADING THIS IS HEADING
  • 13. Java variables JavaScript Variables As with algebra, JavaScript variables are used to hold values or expressions. A variable can have a short name, like x, or a more descriptive name, like car name. Rules for JavaScript variable names: Variable names are case sensitive (y and Y are two different variables) Variable names must begin with a letter or the underscore character Note:Because JavaScript is case-sensitive, variable names are case-sensitive.
  • 14. Declaring (Creating) JavaScript Variables Creating variables in JavaScript is most often referred to as "declaring" variables.You can declare JavaScript variables with the var statement. EXAMPLE: var x;varcarname; Assigning Values to Undeclared JavaScript Variables: If you assign values to variables that have not yet been declared, the variables will automatically be declared. These statements: x=5;carname="Volvo";
  • 15. Redeclaring JavaScript Variables As with algebra, you can do arithmetic operations with JavaScript variables: y=x-5;z=y+5; JavaScript Operators = is used to assign values. + is used to add values. JavaScript Arithmetic Operators Arithmetic operators are used to perform arithmetic between variables and/or values. Given that y=5, the table below explains the arithmetic operators: EXAMPLES: + , -, *, /, %
  • 16. JavaScript Assignment Operators Assignment operators are used to assign values to JavaScript variables. Given that x=10 and y=5, the table below explains the assignment operators: OPERATORS =, += ,-=, *=, /=, %= The + Operator Used on Strings The + operator can also be used to add string variables or text values together. txt1="What a very";txt2="nice day";txt3=txt1+txt2;
  • 17. Adding Strings and Numbers The rule is: If you add a number and a string, the result will be a string! x=5+5;document.write(x);x="5"+"5";document.write(x);x=5+"5";document.write(x);x="5"+5;document.write(x);
  • 19. Logical Operators Logical Operators: Logical operators are used to determine the logic between variables or values. Given that x=6 and y=3, the table below explains the logical operators:
  • 20. Conditional Operator Syntax Example: If the variable visitor has the value of "PRES", then the variable greeting will be assigned the value "Dear President " else i t will be assigned "Dear".
  • 21. Conditional Statements: Very often when you write code, you want to perform different actions for different decisions. You can use conditional statements in your code to do this. In JavaScript we have the following conditional statements: if statement- use this statement to execute some code only if a specified condition is true if...else statement- use this statement to execute some code if the condition is true and another code if the condition is false if...else if....else statement- use this statement to select one of many blocks of code to be executed switch statement - use this statement to select one of many blocks of code to be executed
  • 23. The JavaScript Switch Statement Use the switch statement to select one of many blocks of code to be executed. Syntax
  • 24. JavaScript Popup Boxes Alert Box: An alert box is often used if you want to make sure information comes through to the user.When an alert box pops up, the userwill have to click "OK" to proc Syntax alert("sometext"); Confirm Box A confirm box is often used if you want the user to verify or accept something. When a confirm box pops up, the user will have to click either "OK" or "Cancel" to proceed. If the user clicks "OK", the box returns true. If the user clicks "Cancel", the box returns false. Syntax confirm("sometext");
  • 25. Prompt Box A prompt box is often used if you want the user to input a value before entering a page. When a prompt box pops up, the user will have to click either "OK" or "Cancel" to proceed after entering an input value. If the user clicks "OK" the box returns the input value. If the user clicks "Cancel" the box returns null. Syntax prompt("sometext","defaultvalue");
  • 26.
  • 27. JavaScript Functions To keep the browser from executing a script when the page loads, you can put your script into a function. A function contains code that will be executed by an event or by a call to the function. You may call a function from anywhere within a page (or even from other pages if the function is embedded in an external .js file). Functions can be defined both in the <head> and in the <body> section of a document. However, to assure that a function is read/loaded by the browser before it is called, it could be wise to put functions in the <head> section. How to Define a Function function functionname(var1,var2,...,varX){some code}
  • 28. Events By using JavaScript, we have the ability to create dynamic web pages. Events are actions that can be detected by JavaScript. Every element on a web page has certain events which can trigger a JavaScript. For example, we can use the onClick event of a button element to indicate that a function will run when a user clicks on the button. We define the events in the HTML tags. Examples of events: A mouse click A web page or an image loading Mousing over a hot spot on the web page Selecting an input field in an HTML form Submitting an HTML form A keystroke
  • 29. On Load and on Unload The onLoad event is often used to check the visitor's browser type and browser version, and load the proper version of the web page based on the information. Some of other events onFocus, onBlur and onChange onSubmit onMouseOver and onMouseOut
  • 30. Exception handling When browsing Web pages on the internet, we all have seen a JavaScript alert box telling us there is a runtime error and asking "Do you wish to debug?". Error message like this may be useful for developers but not for users. When users see errors, they often leave the Web page. This chapter will teach you how to catch and handle JavaScript error messages, so you don't lose your audience. Try catch block try  {  //Run some code here  }catch(err)  {  //Handle errors here  }
  • 31. Throw and throws The throw statement allows you to create an exception. If you use this statement together with the try...catch statement, you can control program flow and generate accurate error messages. syntax throw(exception)
  • 32. <html><body><script type="text/javascript">var x=prompt("Enter a number between 0 and 10:","");try  {   if(x>10)    {    throw "Err1";    }  else if(x<0)    {    throw "Err2";    }  else if(isNaN(x))    {    throw "Err3";    }  }>
  • 33. catch(er)  {  if(er=="Err1")    {    alert("Error! The value is too high");    }  if(er=="Err2")    {    alert("Error! The value is too low");    }  if(er=="Err3")    {    alert("Error! The value is not a number");    }  }</script></body></html
  • 34. Insert Special Characters The backslash ( is used to insert apostrophes, new lines, quotes, and other special characters into a text string.
  • 35. JavaScriptObjects JavaScript is an Object Oriented Programming (OOP) language. An OOP language allows you to define your own objects and make your own variable types. Array Object
  • 36.
  • 37. String object The String object is used to manipulate a stored piece of text. String objects are created with new String(). Syntax var txt = new String(string); or var txt = string;
  • 38.
  • 40.
  • 41.
  • 43.
  • 44. appVersion - holds, among other things, the version of the browser Example: <html><body><script type="text/javascript">var browser=navigator.appName;varb_version=navigator.appVersion;var version=parseFloat(b_version);document.write("Browser name: "+ browser);document.write("<br />");document.write("Browser version: "+ version);</script></body></html> OUTPUT: Browser name:Microsoft Internet Explorer Browser version:4
  • 45.
  • 46. Password cookie - The first time a visitor arrives to your web page, he or she must fill in a password. The password is then stored in a cookie. Next time the visitor arrives at your page, the password is retrieved from the cookie
  • 47.
  • 48.
  • 49. whether E-mail id entered by user is valid or not
  • 50. whether Date entered is valid or not
  • 51.
  • 52. with (thisform)  {  if (validate_required(email,"Email must be filled out!")==false)  {email.focus();return false;}  }}</script></head><body><form action="submit.htm" onsubmit="return validate_form(this)" method="post">Email: <input type="text" name="email" size="30"><input type="submit" value="Submit"></form></body></html>
  • 53. JavaScript Objects Creating Your Own Objects There are different ways to create a new object: 1. Create a direct instance of an object The following code creates an instance of an object and adds four properties to it: personObj=new Object();personObj.firstname="John";personObj.lastname="Doe";personObj.age=50;personObj.eyecolor="blue"; 2. Create a template of an object The template defines the structure of an object: function person(firstname,lastname,age,eyecolor){this.firstname=firstname;this.lastname=lastname;this.age=age;this.eyecolor=eyecolor;} With the help of template ,we can create new instances of object like this:
  • 54. EXAMPLE myFather=new person("John","Doe",50,"blue"); myMother=new person("Sally","Rally",48,"green");
  • 55.
  • 56. validating data on the client
  • 57. create more sophisticated user interfaces.
  • 58.
  • 59.
  • 60. JavaScript used to allow script access to objects embedded in otherapplication.
  • 61.
  • 62. Problems due to use of different javascript
  • 63.